<template>
  <div class="report-form-content">
    <van-tabs v-model:active="active">
      <van-tab title="指标信息">
        <el-card class="update-log">
          <div class="shenpilist shenpilist-1">
            <label>指标编码</label>
            <!-- <span>{{ expenditureKpiObj.kpiCode }}</span> -->
          </div>
          <div class="shenpilist shenpilist-1">
            <!-- <label>指标编码</label> -->
            <span>{{ expenditureKpiObj.kpiCode }}</span>
          </div>
          <div class="shenpilist shenpilist-1">
            <label>指标名称</label>
            <span>{{expenditureKpiObj.kpiName}}</span>
          </div>
          <div class="report-form-list-content">
            <div class="shenpilist">
              <label>预算年度</label>
              <span>{{ expenditureKpiObj.year }}</span>
            </div>
            <div class="shenpilist">
              <label>支出类型</label>
              <span>{{ showDictKeyLabel('ExpenditureKpiPayType', expenditureKpiObj.payType) }}</span>
            </div>
            <div class="shenpilist">
              <label>经费类型</label>
              <span>{{ showDictKeyLabel('ExpenditureKpiFundType', expenditureKpiObj.fundType) }}</span>
            </div>
            <div class="shenpilist">
              <label>预算总金额</label>
              <span>￥{{ expenditureKpiObj.amount }}</span>
            </div>
            <div class="shenpilist">
              <label>部门</label>
              <span>{{ showIdLabel(organizationList, expenditureKpiObj.organizationId, 'organizationName') }}</span>
            </div>
            <div class="shenpilist">
              <label>功能分类</label>
              <span>{{ showIdLabel(expenditureFunctionalList, expenditureKpiObj.expenditureFunctionalId, 'name') }}</span>
            </div>
            <div class="shenpilist shenpilist-1">
              <label>财政项目</label>
              <span>{{ showIdLabel(expenditureFiscalList, expenditureKpiObj.expenditureFiscalId, 'name') }}</span>
            </div>
            <div class="shenpilist">
              <label>指标来源</label>
              <span>{{ showDictKeyLabel('ExpenditureKpiSource', expenditureKpiObj.source) }}</span>
            </div>
            <div class="shenpilist">
              <label>项目负责人</label>
              <span>{{ showIdLabel(userList, expenditureKpiObj.managerId, 'name') }}</span>
            </div>
            <div class="shenpilist">
              <label>项目类型</label>
              <span>{{ showIdLabel(expenditurePtypeList, expenditureKpiObj.expenditurePtypeId, 'name') }}</span>
            </div>
          </div>
        </el-card>
      </van-tab>
      <van-tab title="额度下达单信息">
        <el-card class="update-log">
          <div class="report-form-list-content">
            <div class="shenpilist">
              <label>额度下达单编码</label>
              <span>{{ obj.quotaCode }}</span>
            </div>
            <div class="shenpilist">
              <label>日期</label>
              <span>{{ obj.quotaDate?.substring(0, 10) }}</span>
            </div>
            <div class="shenpilist">
              <label>下达金额</label>
              <span>￥{{ obj.amount }}</span>
            </div>
            <div class="shenpilist shenpilist-1">
              <label>财政项目</label>
              <span>{{ showIdLabel(expenditureFiscalList, obj.expenditureFiscalId, 'name') }}</span>
            </div>
            <div class="shenpilist">
              <label>账户</label>
              <span>{{ showIdLabel(expenditureAccountList, obj.expenditureAccountId, 'accountName') }}</span>
            </div>
            <div class="shenpilist">
              <label>会计科目</label>
              <span>{{ showIdLabel(expenditureSubjectList, obj.expenditureSubjectId, 'name') }}</span>
            </div>
            <div class="shenpilist">
              <label>填单人部门</label>
              <span>{{ showIdLabel(organizationList, obj.submitOrganizationId, 'organizationName') }}</span>
            </div>
            <div class="shenpilist">
              <label>填单人用户</label>
              <span>{{ showIdLabel(userList, obj.submitUserId, 'name') }}</span>
            </div>
            <div class="shenpilist">
              <label>结算方式</label>
              <span>{{ showDictKeyLabel('ExpenditureSettlement', obj.settlement) }}</span>
            </div>
            <div class="shenpilist">
              <label>状态</label>
              <span>{{ showEnumLabel('ExpenditureQuotaState', obj.state) }}</span>
            </div>
          </div>
          <div class="shenpilist shenpilist-1">
            <label>摘要</label>
            <!-- <span>{{ obj.summary }}</span> -->
          </div>
          <div class="shenpilist shenpilist-1">
            <!-- <label>摘要</label> -->
            <span>{{ obj.summary }}</span>
          </div>
        </el-card>
      </van-tab>
    </van-tabs>
  </div>
</template>
<script setup>
import {ref, computed, watch} from 'vue'
import {doGet} from "@/config/http";
import {svc, showDictKeyLabel, showEnumKeyLabel, showIdLabel, getListPageSize, showEnumLabel} from "@/config/common";
import initListStore from '@/store/modules/initList'

const props = defineProps({
  expenditureQuotaId: {
    required: true,
    type: String,
  }
})

const emit = defineEmits(['close'])

// tab 切换
let activeName = ref('first')
// 基本数据
let obj = ref({})

// 指标单数据
let expenditureKpiObj = ref({})

let governmentList = initListStore().governmentList
let organizationList = initListStore().organizationList
let userList = initListStore().userList
let expenditurePtypeList = initListStore().expenditurePtypeList//项目类型
let expenditureFunctionalList = initListStore().expenditureFunctionalList//功能分类
let expenditureEconomicList = initListStore().expenditureEconomicList//经济分类
let expenditureFiscalList = initListStore().expenditureFiscalList//财政项目
let expenditureSubjectList = initListStore().expenditureSubjectList//会计科目

let attachmentVisible = ref(false)
let attachmentObj = ref(null)

watch(() => props.expenditureQuotaId, async val => {
  await initObj(val)
  // await initList()
},{immediate:true})

// 获取下拉框数据列表
// async function initList() {
//   let p1 = doGet(svc, '/government/page', {pageSize: getListPageSize()}, false)
//   let p2 = doGet(svc, '/organization/page', {pageSize: getListPageSize()}, false)
//   let p3 = doGet(svc, '/user/page', {pageSize: getListPageSize()}, false)
//   let p4 = doGet(svc, '/expenditure-ptype/page', {pageSize: getListPageSize()}, false)
//   let p5 = doGet(svc, '/expenditure-functional/page', {pageSize: getListPageSize()}, false)
//   let p6 = doGet(svc, '/expenditure-economic/page', {pageSize: getListPageSize()}, false)
//   let p7 = doGet(svc, '/expenditure-fiscal/page', {pageSize: getListPageSize()}, false)
//   let p8 = doGet(svc, '/expenditure-subject/page', {pageSize: getListPageSize()}, false)
//   let p9 = doGet(svc, '/expenditure-account/page', {pageSize: getListPageSize()}, false)
//   let resArray = await Promise.all([p1, p2, p3, p4, p5, p6, p7, p8, p9])
//   governmentList.value = resArray[0]['records']
//   organizationList.value = resArray[1]['records']
//   userList.value = resArray[2]['records']
//   expenditurePtypeList.value = resArray[3]['records']
//   expenditureFunctionalList.value = resArray[4]['records']
//   expenditureEconomicList.value = resArray[5]['records']
//   expenditureFiscalList.value = resArray[6]['records']
//   expenditureSubjectList.value = resArray[7]['records']
//   expenditureAccountList.value = resArray[8]['records']
// }

// 获取数据
async function initObj(id) {
  obj.value = await doGet(svc, '/expenditure-quota/' + id, {}, true)
  expenditureKpiObj.value = await doGet(svc, '/expenditure-kpi/' + obj.value.expenditureKpiId, {}, false)
  console.log(expenditureKpiObj.value.expenditureFiscalId)
}

function closeBtn() {
  attachmentVisible.value = false
}
</script>

<style scoped lang="scss">
.report-form-content {
  width: 100%;
  height: 52vh;
  overflow-x: hidden;
  overflow-y: auto;
}
.report-form-content-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.file-list-btn {
  display: flex;
  /* display: flex; */
  align-items: center;
  justify-content: space-between
}
.report-form-list-content .el-form-item__label {
  width: 220px !important;
}
.el-form-item__label {
  width: 220px !important;
}
.report-form-list-content {
  display: flex;
  flex-wrap: wrap;
}

.form-label {
  display: inline-flex;
  justify-content: flex-end;
  align-items: flex-start;
  flex: 0 0 auto;
  /* font-size: var(--el-form-label-font-size); */
  font-size: 16px;
  /* color: var(--el-text-color-regular); */
  color: #337ecc;
  height: 32px;
  line-height: 32px;
  padding: 0 12px 0 0;
  box-sizing: border-box;
  width: 200px;
  font-weight: bold;
}
.update-log {
  width: 100%;
  margin-top: 0;
  margin-bottom: 30px;
}
.select-list {
  width: 100%;
  margin: 30px 0;
  display: flex;
  align-items: center;
  /* justify-content: space-between; */
}
.select-list .el-radio-group {
  margin-right: 30px;
}
.select-list .el-button {
  margin-left: 30px;
}
.add-indexs {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.upload-demo {
  margin-right: 20px;
}
.file-list {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px 0;
}
.file-list-btns {
  display: flex;
  align-items: center;
}
.file-list-btn-span {
  color: #F56C6C;
  font-size: 12px;
}
.shenpilist {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--van-cell-background);
  box-sizing: border-box;
  width: 100%;
  padding: var(--van-cell-vertical-padding) var(--van-cell-horizontal-padding);
  overflow: hidden;
  color: var(--van-cell-text-color);
  font-size: var(--van-cell-font-size);
  // line-height: var(--van-cell-line-height);
  border-bottom: 1px solid var(--van-border-color);;
  & label {
    color: var(--van-field-label-color);
    // text-align: left;
    word-wrap: break-word;
    font-weight: 700;
  }
  & span {
    // display: block;
    box-sizing: border-box;
    // width: 100%;
    color: var(--van-field-input-text-color);
    line-height: inherit;
    // text-align: left;
    background-color: transparent;
    border: 0;
    resize: none;
    -webkit-user-select: auto;
    user-select: auto;
  }
}
.shenpilist-head {
  color: var(--van-cell-text-color);
  font-size: var(--van-cell-font-size);
  font-weight: 700;
  padding: .3125rem 0;
  padding-left: 1.125rem;
  color: #337ecc;
}
</style>
